﻿/*
-----------------------------------------------------------------------------
This source file is part of Cell Cloud.

Copyright (c) 2009-2012 Cell Cloud Team (cellcloudproject@gmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/

#ifndef CellCelletFeature_h
#define CellCelletFeature_h

#include "CellPrerequisites.h"

namespace cell
{
/** \addtogroup Core
	*  @{
	*/
/** \addtogroup General
	*  @{
	*/

/** Cellet 版本信息描述。
@author
	Jiangwei Xu
*/
class _CellExport CelletVersion : public CelletAlloc
{
public:
	/** 默认构造函数。
	*/
	CelletVersion(void);

	/** 构造函数。
	*/
	CelletVersion(int major, int minor, int revision);

	/** 拷贝构造函数。
	*/
	CelletVersion(const CelletVersion& other);

	/** 析构函数。
	*/
	virtual ~CelletVersion(void);

public:
	/** 赋值操作符。
	*/
	CelletVersion& operator=(const CelletVersion& r);

	/** 等于操作符。
	*/
	inline bool operator==(const CelletVersion& other) const
	{
		if (mMajor == other.mMajor &&
			mMinor == other.mMinor &&
			mRevision == other.mRevision)
			return true;
		return false;
	}

	/** 主版本号。
	*/
	inline int getMajor(void) const { return mMajor; }

	/** 副版本号。
	*/
	inline int getMinor(void) const { return mMinor; }

	/** 修订号。
	*/
	inline int getRevision(void) const { return mRevision; }

	/**
	*/
	String toString(void) const;

private:
	int mMajor;
	int mMinor;
	int mRevision;
};


/** Cellet 特性描述。CelletFeature 用于唯一标识 Cellet 。
@author
	Jiangwei Xu
*/
class _CellExport CelletFeature : public CelletAlloc
{
public:
	/** 默认构造函数。
	*/
	CelletFeature(void);

	/** 构造函数。
	*/
	CelletFeature(const String& identifier, const CelletVersion& version);

	/** 拷贝构造函数。
	*/
	CelletFeature(const CelletFeature& other);

	/** 析构函数。
	*/
	virtual ~CelletFeature(void);

public:
	/** 赋值操作符。
	*/
	const CelletFeature& operator=(const CelletFeature& r);

	/** 返回标识符。
	*/
	const String& getIdentifier(void) const;

	/** 返回版本号。
	*/
	const CelletVersion& getVersion(void) const;

private:
	String mIdentifier;
	CelletVersion mVersion;

	friend class Cellet;
};

/** @} */
/** @} */
} // end namespace cell

#endif // CellCelletFeature_h
